class Token < ActiveRecord::Base
  belongs_to :user

  before_save :fill_it

  def still_valid?
    expires_at && (Time.now.utc < expires_at)
  end

protected
  # before filter 
  def fill_it
    self.token_value= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{rand(65536).to_s}")
    self.expires_at = 1.hour.from_now.utc
  end
end
